package service.impl;

import dao.DeptDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pojo.Dept;
import service.DeptService;

import java.util.List;
@Service("deptService")
public class DeptServiceImpl implements DeptService {
    //先生成一个Dao对象
    // 再通过Dao对象调用方法
    @Autowired
    private DeptDao deptdao;
    @Override
    public int addDept(String dname) {
        return deptdao.addDept(dname);
    }

    @Override
    public int deleteDeptById(int id) {
        return deptdao.deleteDeptById(id);
    }

    @Override
    public int updateDept(Dept dept) {
        return deptdao.updateDept(dept);
    }

    @Override
    public List<Dept> findAll(Dept dept,int offset,int pageSize) {

        List<Dept> depts=deptdao.findAll2(dept,offset,pageSize);
        return depts;
    }


    @Override
    public Dept findById(int id) {
        return deptdao.findById(id);
    }

    @Override
    public boolean login(Dept dept) {
        if(deptdao.login()>0){
            return true;
        }else{
            return false;
        }
    }

    @Override
    public int count(Dept dept) {
        return deptdao.count(dept);
    }
}
